package IO流.InputStream01;

import org.junit.jupiter.api.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@SuppressWarnings({"all"})
public class fileCopy {
    public static void main(String[] args) {

    }
    @Test
    public void fileCopy01(){
        String srcFilePath = "src/main/java/IO流/InputStream01.png";
        String desFilePath = "src/main/java/IO流/InputStream01/InputStream01.png";

        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;

        try {
            fileInputStream = new FileInputStream(srcFilePath);
            fileOutputStream = new FileOutputStream(desFilePath);

            //定义一个字节数组，提高读取效率
            byte[] buff = new byte[1024];
            int readLen = 0;
            while ((readLen = fileInputStream.read(buff)) != -1){
//                System.out.println(new String(buff,0,readLen));
                fileOutputStream.write(buff,0,readLen);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
